home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 433_01 / svgademo.c < prev    next >
C/C++ Source or Header  |  1994-05-08  |  15KB  |  612 lines

  1. /****************************************************************************
  2.      
  3.       'SVGACC' A Super Vga Graphics Library for use with Microsoft and
  4.       Borland C/C++
  5.       Copyright 1993-1994 by Stephen L. Balkum and Daniel A. Sill
  6.  
  7.       GIF and 'Graphics Intechange Format' are trademarks (tm) of
  8.       Compuserve, Incorporated, an H&R Block Company.
  9.  
  10.     **************** UNREGISTERD SHAREWARE VERSION ***********************
  11.     * FOR EVUALATION ONLY. NOT FOR RESALE IN ANY FORM. SOFTWARE WRITTEN  *
  12.     * USING THIS UNREGISTERED SHAREWARE GRAPHICS LIBRARY MAY NOT BY SOLD *
  13.     * OR USED FOR ANY PURPOSE OTHER THAN THE EVUALTION OF THIS LIBRARY.  *
  14.     **********************************************************************
  15.  
  16.     **************** NO WARRANTIES AND NO LIABILITY **********************
  17.     * Stephen L. Balkum and Daniel A. Sill provide no warranties, either *
  18.     * expressed or implied, of merchantability, or fitness, for a        *
  19.     * particular use or purpose of this SOFTWARE and documentation.      *
  20.     * In no event shall Stephen L. Balkum or Daniel A. Sill be held      *
  21.     * liable for any damages resulting from the use or misuse of the     * 
  22.     * SOFTWARE and documentation.                                        *
  23.     **********************************************************************
  24.  
  25.     ************** U.S. GOVERNMENT RESTRICTED RIGHTS *********************
  26.     * Use, duplication, or disclosure of the SOFTWARE and documentation  *
  27.     * by the U.S. Government is subject to the restictions as set forth  *
  28.     * in subparagraph (c)(1)(ii) of the Rights in Technical Data and     *
  29.     * Computer Software cluse at DFARS 252.227-7013.                     *
  30.     * Contractor/manufacturer is Stephen L. Balkum and Daniel A. Sill,   *
  31.     * P.O. Box 7704, Austin, Texas 78713-7704                            *
  32.     **********************************************************************
  33.  
  34.     **********************************************************************
  35.     * By using this SOFTWARE or documentation, you agree to the above    *
  36.     * terms and conditions.                                              *
  37.     **********************************************************************
  38.  
  39.  ***************************************************************************/
  40.     
  41.  
  42. #include <stdio.h>
  43. #include <conio.h>
  44. #include <stdlib.h>
  45. #include <string.h>
  46. #include <math.h>
  47. #include <dos.h>
  48.  
  49. #include "svgacc.h"
  50.  
  51. #include "svgademo.h"
  52.  
  53.  
  54. void main(void) {
  55.  
  56.     int startvideomode;
  57.     int i, max, ky;
  58.     int mjv, mnv, tp;
  59.     int cpu, videomemory;
  60.     int mouse, joystick;
  61.     int res;
  62.     int offset, colr;
  63.     float mypi;
  64.     char dummy;
  65.     char buf[TITLEN];
  66.     char *dumptr;
  67.     
  68.     
  69.     /*
  70.      * Save the starting videomode and set it to mode 3.
  71.      */
  72.     startvideomode = videomodeget();
  73.     restext();
  74.     screenclear();
  75.     
  76.     /*
  77.      * Move the DOS cursor to the top left to start the program and say hello
  78.      */
  79.     screengoto(11,0);
  80.     printf("/*SVGACC.LIB/* A SuperVGA Graphics Library for use with\n");
  81.     screengoto(23,1);
  82.     printf("Microsoft and Borland C/C++\n");
  83.     screengoto(9,2);
  84.     printf("Copyright 1993-1994 by Stephen L. Balkum and Daniel A. Sill\n");
  85.     screengoto(23,11);
  86.     printf("Demonstration/Example Program\n");
  87.     screengoto(0,22);
  88.     printf("press a key to begin the demo...\n");
  89.     getkey();
  90.  
  91.     screenclear();
  92.    
  93.     /*
  94.      * Let's id the processor first as the library requires a 386 or better.
  95.      */
  96.     screengoto(0,0);
  97.     cpu = whichcpu();
  98.     if (cpu < 386) {
  99.         printf("Sorry, this library requires an 80386 or better processor.\n");
  100.         printf("Processor is identified as an 80%d.\n", cpu);
  101.         printf("Demo program will be terminated.\n\n");
  102.         printf("press a key...\n");
  103.         getkey();
  104.         videomodeset(startvideomode);
  105.         exit(0);
  106.     }
  107.  
  108.  
  109.     /*
  110.      * Let's id the video card/chip as the library requires a SuperVGA adapter.
  111.      */
  112.     switch(whichvga()) {
  113.         case ACUMOS:
  114.             sprintf(buf,"Acumos AVGA2/3 SuperVGA");
  115.             break;
  116.         case ATI:
  117.             sprintf(buf,"ATI Technologies 18/28/38/68800 SuperVGA");
  118.             break;
  119.         case AHEADA:
  120.             sprintf(buf,"Ahead V5000 Ver A SuperVGA");
  121.             break;
  122.         case AHEADB:
  123.             sprintf(buf,"Ahead V5000 Ver B SuperVGA");
  124.             break;
  125.         case CHIPSTECH:
  126.             sprintf(buf,"Chips and Technologies 82C450/1/2/3/5/6/7 SuperVGA");
  127.             break;
  128.         case CIRRUS:
  129.             sprintf(buf,"Cirrus Logic CL-GD 5xx,6xx,28xx,54xx,62xx SuperVGA");
  130.             break;
  131.         case EVEREX:
  132.             sprintf(buf,"Everex EV236/6xx Micro Enhancer SuperVGA");
  133.             break;
  134.         case GENOA:
  135.             sprintf(buf,"Genoa 61/62/63/64/6600 SuperVGA");
  136.             break;
  137.         case NCR:
  138.             sprintf(buf,"NCR 77C21/22/22E/22E+ SuperVGA");
  139.             break;
  140.         case OAKTECH:
  141.             sprintf(buf,"Oak Technologies OTI-037/67/77/87C SuperVGA");
  142.             break;
  143.         case PARADISE:
  144.             sprintf(buf,"Paradise/Western Digital PVGA1A,WD90C00/1x/2x/3x SuperVGA");
  145.             break;
  146.         case REALTEK:
  147.             sprintf(buf,"Realtek RT3106 SuperVGA");
  148.             break;
  149.         case TRIDENT:
  150.             sprintf(buf,"Trident 8800CS,8900B/C/CL/CX,90x0 SuperVGA");
  151.             break;
  152.         case TSENG3:
  153.             sprintf(buf,"Tseng Labs ET3000-AX/BX/BP SuperVGA");
  154.             break;
  155.         case TSENG4:
  156.             sprintf(buf,"Tseng Labs ET4000/W32/W32I SuperVGA");
  157.             break;
  158.         case VESA:
  159.             sprintf(buf,"VESA compatible SuperVGA");
  160.             break;
  161.         case VIDEO7:
  162.             sprintf(buf,"Video 7 HT-208/16 SuperVGA");
  163.             break;
  164.         case AVANCE:
  165.             sprintf(buf,"Avance Logic AL2101 SuperVGA");
  166.             break;
  167.         case MXIC:
  168.             sprintf(buf,"MXIC MX68000/10 SuperVGA");
  169.             break;
  170.         case PRIMUS:
  171.             sprintf(buf,"Primus P2000 SuperVGA");
  172.             break;
  173.         default:
  174.             printf("Microprocessor is identified as an 80%d.\n", cpu);
  175.             printf("Sorry, unable to identify video card or it is not a SuperVGA video adapter.\n");
  176.             printf("Demo program will be terminated.\n\n");
  177.             printf("press a key...\n");
  178.             getkey();
  179.             videomodeset(startvideomode);
  180.             exit(0);
  181.     }
  182.     printf("Microprocessor is identified as an 80%d.\n", cpu);
  183.     
  184.     fontsystem();
  185.     printf("Video card/chip is identified as %s.\n",&buf);
  186.    
  187.     /*
  188.      * Let's see the how much memory is installed on the super vga adapter.
  189.      */
  190.     videomemory = whichmem();
  191.     if (videomemory < 1) {
  192.         printf("Sorry, unable to identify the amount of installed video memory.\n");
  193.         printf("Demo program will be terminated.\n\n");
  194.         printf("press a key...\n");
  195.         getkey();
  196.         videomodeset(startvideomode);
  197.         exit(0);
  198.     } else
  199.         printf("Installed video memory identified as %dkb.\n", videomemory);
  200.        
  201.     /*
  202.      * Let's tell the user what the highest resolution that the video card
  203.      * and its installed memory card is capable of. The monitor must be able
  204.      * to support those modes too !
  205.      */
  206.     printf("Video card and installed memory is capable of the following resolutions:\n");
  207.     if (videomemory > 2047) {
  208.         printf("    320x200 in 256 colors\n");
  209.         printf("    640x400 in 256 colors\n");
  210.         printf("    640x480 in 256 colors\n");
  211.         printf("    800x600 in 256 colors\n");
  212.         printf("    1024x768 in 256 colors\n");
  213.         printf("    1280x1024 in 256 colors\n");
  214.         max = 5;
  215.     } else if (videomemory > 1023) {
  216.         printf("    320x200 in 256 colors\n");
  217.         printf("    640x400 in 256 colors\n");
  218.         printf("    640x480 in 256 colors\n");
  219.         printf("    800x600 in 256 colors\n");
  220.         printf("    1024x768 in 256 colors\n");
  221.         max = 4;
  222.     } else if (videomemory > 511) {
  223.         printf("    320x200 in 256 colors\n");
  224.         printf("    640x400 in 256 colors\n");
  225.         printf("    640x480 in 256 colors\n");
  226.         printf("    800x600 in 256 colors\n");
  227.         max = 3;
  228.     } else {
  229.         printf("    320x200 in 256 colors\n");
  230.         printf("    640x400 in 256 colors\n");
  231.         max = 1;
  232.     }
  233.     printf("\nPlease keep in mind that not all monitors support all resolutions. If You\n");
  234.     printf("know your monitor will not work properly at very high resolution(ie 1024x768\n");
  235.     printf("or 1280x1024) then do NOT attempt to run the demo in that resolution.\n\n");
  236.  
  237.     /*
  238.      * Let's look for a mouse. if we find one, tell all about it
  239.      */
  240.     mouse = whichmouse();
  241.     if (mouse > 0) {
  242.         mouseinfo(&mjv, &mnv, &tp, &i);
  243.         switch (tp) {
  244.             case 1:
  245.                 sprintf(buf,"bus mouse");
  246.                 break;
  247.             case 2:
  248.                 sprintf(buf,"serial mouse");
  249.                 break;
  250.             case 3:
  251.                 sprintf(buf,"Inport mouse");
  252.                 break;
  253.             case 4:
  254.                 sprintf(buf,"PS/2 mouus